package com.labichaoka.chaoka.ui.home.fragment.my.record;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;

import com.labichaoka.chaoka.R;
import com.labichaoka.chaoka.base.BaseActivity;
import com.labichaoka.chaoka.entity.WithdrawRecordInfoResponse;
import com.labichaoka.chaoka.utils.ToastUtils;

import butterknife.BindView;

public class WithDrawRecordActivity extends BaseActivity implements WithDrawRecordView{
    @BindView(R.id.list)
    RecyclerView recyclerView;
    @BindView(R.id.empty_layout)
    RelativeLayout emptyLayout;

    private WithDrawRecordPresenter presenter;

    @Override
    protected int initLayoutId() {
        return R.layout.activity_with_draw_record;
    }

    @Override
    protected void initView() {
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    protected void initData() {
        presenter=new WithdrawRecordPresenterImpl(this,new WithdrawRecordInteractorImpl());
        presenter.getWithdrawRecordInfo();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void showProgress() {
        showLoadingProgress();
    }

    @Override
    public void hideProgress() {
        hideLoadingProgress();
    }

    @Override
    public void showMessage(String str) {
        ToastUtils.show(str);
    }

    @Override
    public void getWithdrawRecordInfoCallback(WithdrawRecordInfoResponse response) {
        if (response.getData()==null){
            return;
        }
        if (response.getData().size()>0){
            emptyLayout.setVisibility(View.GONE);
        }else{
            emptyLayout.setVisibility(View.VISIBLE);
        }
        WithdrawRecordAdapter adapter=new WithdrawRecordAdapter(response.getData());
        recyclerView.setAdapter(adapter);
    }
}
